package com.example.demo.dao;

import com.example.demo.entity.Evaluate;
import com.example.demo.entity.Goods;
import com.example.demo.entity.Shop;
import com.example.demo.entity.Type;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import javax.lang.model.element.TypeElement;
import java.util.List;

@Mapper
@Repository
public interface GoodsDAO {
    public List<Goods> findAllGoods(Shop shop);

    public Goods findGoodsById(@Param("goodsid") int goodsid);

    public List<Goods> findGoodsByType(Goods goods);

    public void updateGoodsNum(Goods goods);

    public List<Evaluate> findGoodsEvaluate(Evaluate evaluate);

    public void insertGoodsEvaluate(Evaluate evaluate);

    public Evaluate searchEvaluate(Evaluate evaluate);

    public Type getTypeByName(Type type);

    public List<Type> getAllTypes();



    public void insertType(Type type);

    public void updateVolume(Type type);

    List<Goods> findGoodsBySidAndMsg(@Param("sid") int sid,@Param("searchMsg") String searchMsg,@Param("start") int start);
    int findAllGoodsBySidAndMsgTotal(@Param("sid") int sid,@Param("searchMsg") String searchMsg);
    @Delete("delete from goods where goodsid = #{id}")
    void deleteGoodsById(int id);
    @Update("update goods set name=#{name}," +
            "type = #{type}," +
            "price = #{price}," +
            "picaddress = #{picaddress}," +
            "num = #{num} " +
            "where goodsid = #{goodsid}")
    void editGoods(Goods goods);

    @Insert("insert into goods (name,price,picaddress,num,type,shopid) values (#{name},#{price},#{picaddress},#{num},#{type},#{shopid})")
    void addGoods(Goods goods);

    @Select("select * from type where type=#{id}")
    Type getTypeById(@Param("id") int id);
}
